<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2017/4/6
  Time: 20:16
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<html>
<head>
    <title>Title</title>
    <link rel="stylesheet" type="text/css" href="<%=basePath%>/js/jquery-easyui-1.4/themes/default/easyui.css">

    <script src="<%=basePath%>/js/jquery.min.js"></script>
    <script src="<%=basePath%>/js/jquery-easyui-1.4/jquery.easyui.min.js  "></script>
    <script>
        var i=1;
        function addTab(title, url){
            var idn ="sss" + i++;
            if ($('#tt').tabs('exists', title)){
                $('#tt').tabs('select', title);
            } else {
                var content = '<iframe scrolling="auto" id="'+idn+'" frameborder="0" style="width:100%;height:100%;"></iframe>';
                $('#tt').tabs('add',{
                    title:title,
                    content:content,
                    closable:true
                });
                $("#"+ idn).attr("src",url);
            }
        }
        $(function(){
            /*用id写能直接定位到都dom元素，应为dom元素的结构已经改变，属性选择器会找不到那个dom元素*/
           /* $(" div[title='top'] > iframe" ).attr("src","tiaozhuan/top.do");*/
            $("#iframe1").attr("src","<%=basePath%>tiaozhuan/top.do");
            $("#iframe2").attr("src","<%=basePath%>tiaozhuan/left.do");
            })
    </script>
</head>
<body>
<div style="margin-bottom:10px">
    <a href="#" class="easyui-linkbutton" onclick="addTab('google','http://www.google.com')">google</a>
    <a href="#" class="easyui-linkbutton" onclick="addTab('jquery','http://jquery.com/')">jquery</a>
    <a href="#" class="easyui-linkbutton" onclick="addTab('easyui','http://jeasyui.com/')">easyui</a>
    <a href="#" class="easyui-linkbutton" onclick="addTab('baidu','http://www.baidu.com/')">easyui</a>
</div>
<div id="tt" class="easyui-tabs" style="width:100%;height:100%;">
    <div title="top">
        <%-- 直接把src 写进去，会运行两次src方法，写在外边只调用一次--%>
        <iframe  id="iframe1" scrolling="auto" frameborder="0"></iframe>
    </div>
    <div title="left">
        <iframe id="iframe2" scrolling="auto" frameborder="0"></iframe>
    </div>
</div>
</body>
</html>
